package com.yanqu.road.entity.musicroom;


import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.utils.property.Property;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@FieldTypeAnnotation(tableName = "t_u_music_room_building", autoSave = true, desc = "妙音坊建筑数据")
public class UserMusicRoomBuildingData extends DataObject {

    @FieldTypeAnnotation(desc = "用户Id", select = true, update = true)
    private long userId;

    @FieldTypeAnnotation(desc = "建筑id", update = true)
    private int buildId;

    @FieldTypeAnnotation(desc = "累计奖励")
    private Property amountReward = new Property();

    @FieldTypeAnnotation(desc = "家具")
    private List<MusicRoomFurnitureInfo> furnitureInfos = new ArrayList<>();


    /***** 以下属性不入库,临时计算出来 ***/
    private int totalFurnitureLevel; // 家具总等级
    private List<List<Property>> produceExpBookList = new ArrayList<>(); // 生产经验书列表
    private List<List<Property>> produceSupportItemList = new ArrayList<>(); // 生产应援物列表

    private long supportMoneyAmount; // 应援币产出

    public UserMusicRoomBuildingData() {
    }

    public UserMusicRoomBuildingData(long userId, int buildId) {
        this.userId = userId;
        this.buildId = buildId;
        setInsertOption();
    }

    /**
     * 当前入住的美女
     */
    private Set<Integer> nowCheckInBeautyIds = new HashSet<>();

    /**
     * 即将入住的美女
     */
    private Set<Integer> waitCheckInBeautyIds = new HashSet<>();

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
        setUpdateOption();
    }

    public int getBuildId() {
        return buildId;
    }

    public void setBuildId(int buildId) {
        this.buildId = buildId;
        setUpdateOption();
    }

    public Property getAmountReward() {
        return amountReward;
    }

    public void setAmountReward(Property amountReward) {
        this.amountReward = amountReward;
        setUpdateOption();
    }

    public List<MusicRoomFurnitureInfo> getFurnitureInfos() {
        return furnitureInfos;
    }

    public MusicRoomFurnitureInfo getFurnitureInfo(int furnitureId) {
        for (MusicRoomFurnitureInfo furnitureInfo : furnitureInfos) {
            if (furnitureInfo.getId() == furnitureId) {
                return furnitureInfo;
            }
        }
        return null;
    }

    public void setFurnitureInfos(List<MusicRoomFurnitureInfo> furnitureInfos) {
        this.furnitureInfos = furnitureInfos;
        setUpdateOption();
    }

    public List<Integer> getNowCheckInBeautyIds() {
        return new ArrayList<>(nowCheckInBeautyIds);
    }

    public void addNowBeautyId(int beautyId) {
        if (nowCheckInBeautyIds.contains(beautyId)) {
            return;
        }
        nowCheckInBeautyIds.add(beautyId);
    }

    public void removeNowBeautyId(int beautyId) {
        nowCheckInBeautyIds.remove(beautyId);
    }

    public void clearNowBeautyIds() {
        nowCheckInBeautyIds.clear();
    }

    public void addFurnitureInfo(MusicRoomFurnitureInfo furnitureInfo) {
        furnitureInfos.add(furnitureInfo);
        setUpdateOption();
    }

    public int getTotalFurnitureLevel(){
        return totalFurnitureLevel;
    }

    public List<Integer> getWaitCheckInBeautyIds() {
        return new ArrayList<>(waitCheckInBeautyIds);
    }

    /**
     * 添加即将入住的美女
     * @param beautyId
     */
    public void addWaitCheckInBeautyId(int beautyId) {
        if (waitCheckInBeautyIds.contains(beautyId)) {
            return;
        }
        waitCheckInBeautyIds.add(beautyId);
    }

    public void setNowCheckInBeautyIds(Set<Integer> nowCheckInBeautyIds) {
        this.nowCheckInBeautyIds = nowCheckInBeautyIds;
    }

    public void setWaitCheckInBeautyIds(Set<Integer> waitCheckInBeautyIds) {
        this.waitCheckInBeautyIds = waitCheckInBeautyIds;
    }

    public void removeWaitBeautyId(int beautyId) {
        waitCheckInBeautyIds.remove(beautyId);
    }

    public void clearWaitBeautyIds() {
        waitCheckInBeautyIds.clear();
    }

    public void setTotalFurnitureLevel(int totalFurnitureLevel) {
        this.totalFurnitureLevel = totalFurnitureLevel;
    }

    public List<List<Property>> getProduceExpBookList() {
        return produceExpBookList;
    }

    public void setProduceExpBookList(List<List<Property>> produceExpBookList) {
        this.produceExpBookList = produceExpBookList;
    }

    public List<List<Property>> getProduceSupportItemList() {
        return produceSupportItemList;
    }

    public void setProduceSupportItemList(List<List<Property>> produceSupportItemList) {
        this.produceSupportItemList = produceSupportItemList;
    }

    public long getSupportMoneyAmount() {
        return supportMoneyAmount;
    }

    public void setSupportMoneyAmount(long supportMoneyAmount) {
        this.supportMoneyAmount = supportMoneyAmount;
    }

    public void addAmountReward(Property property) {
        amountReward.addProperty(property);
        setUpdateOption();
    }
}
